//
//  UtilViewController.swift
//  funcode
//
//  Created by Wan Jiading on 2016/11/10.
//  Copyright © 2016年 WanJiading. All rights reserved.
//

import UIKit

class UtilViewController: UITableViewController {
	
	let utilCell = "UtilCell"
	
	var utilList: [UtilModel]! = [
		UtilModel("雾霾", "http://www.okoer.com/report/breathingmask201603",
			"评级：\n" +
			"（A）3M 9502评级获优；\n" +
			"（B）德国DACH245、D7002霍尼韦尔、JACKSON SAFETY 3款口罩的评级为良；\n" +
			"（C）3M 9002、滴露评级为中；\n" +
			"（D）白元、三次元彩虹系列、三次元4D、瑞世普4款口罩评级为差。\n"
		),
		UtilModel("口罩", "http://www.92808.com/article-xwzx_hydt-235.html",
			"FFP3>FFP2=N95=KN95>KN90"),
		UtilModel("百度测试", "https://www.baidu.com",
			"这是百度测试，可以返回了"),
	]
	
    override func viewDidLoad() {
        super.viewDidLoad()

		
		initData()
    }
	
	func initData() {
		self.navigationItem.title = "工具"
	}

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

// MARK: - UITableViewDatasource UITableViewDelegate

extension UtilViewController {
	
	override func numberOfSections(in tableView: UITableView) -> Int {
		return 1
	}
	
	override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
		return utilList.count
	}
	
	override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
		return 50
	}
	override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
		let cell = tableView.dequeueReusableCell(withIdentifier: utilCell) as! UtilCell
		cell.utilModel = utilList[indexPath.row]
		return cell
	}
	
	
	
	override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
		
		let utilModel = utilList[indexPath.row]
		let vc = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "UtilDetail") as! UtilDetailViewController
		vc.utilModel = utilModel
		self.navigationController?.pushViewController(vc, animated: true)
		
	}
}
